/*
 * MidletTeste.java
 *
 * Created on 17 de Maio de 2007, 05:42
 */

package br.com.dreamsource.mobile.worders.tests;

import br.com.dreamsource.mobile.worders.remote.WSController;
import br.com.dreamsource.mobile.worders.remote.WSRequest;
import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//import org.ksoap.SoapObject;
//import org.ksoap.transport.HttpTransport;

/**
 *
 * @author eliseu//
 */
public class MidletTeste extends MIDlet {
    
    /** Creates a new instance of MidletTeste */
    public MidletTeste() {
    }
    
// --- This section is auto-generated by NetBeans IDE. Do not modify or you may lose your changes.//<editor-fold id="MVDMethods" defaultstate="collapsed" desc="This section is auto-generated by NetBeans IDE.">//GEN-BEGIN:MVDMethods
    /**
     * This method initializes UI of the application.
     */
    private void initialize() {
// For adding user code into this block, select "Design" item in the inspector and invoke property editor on Action property in Properties window.
        javax.microedition.lcdui.Display.getDisplay(this).setCurrent(get_form1());
    }
    
    /**
     * This method returns instance for form1 component and should be called instead of accessing form1 field directly.
     * @return Instance for form1 component
     **/
    private javax.microedition.lcdui.Form get_form1() {
        if (form1 == null) {
            form1 = new javax.microedition.lcdui.Form(null, new javax.microedition.lcdui.Item[] {
                get_stringItem1(),
                        get_stringItem2(),
                        get_textField1()
            });
        }
        return form1;
    }
    
    /**
     * This method returns instance for stringItem1 component and should be called instead of accessing stringItem1 field directly.
     * @return Instance for stringItem1 component
     **/
    private javax.microedition.lcdui.StringItem get_stringItem1() {
        if (stringItem1 == null) {
            stringItem1 = new javax.microedition.lcdui.StringItem("Informa\u00E7ao", "Esta e a primeira inicializa\u00E7ao do sistema por favor, digite um nome de usuario e senha para inicializar o sistema.");
        }
        return stringItem1;
    }
    
    /**
     * This method returns instance for stringItem2 component and should be called instead of accessing stringItem2 field directly.
     * @return Instance for stringItem2 component
     **/
    private javax.microedition.lcdui.StringItem get_stringItem2() {
        if (stringItem2 == null) {
            stringItem2 = new javax.microedition.lcdui.StringItem("Aten\u00E7ao", "Guarde bem os dados digitados, eles serao solicitados em todas as inicializa\u00E7oes do sistema.", javax.microedition.lcdui.Item.BUTTON);
        }
        return stringItem2;
    }
    
    /**
     * This method returns instance for textField1 component and should be called instead of accessing textField1 field directly.
     * @return Instance for textField1 component
     **/
    private javax.microedition.lcdui.TextField get_textField1() {
        if (textField1 == null) {
            textField1 = new javax.microedition.lcdui.TextField("textField1", null, 10, 0x10000);
        }
        return textField1;
    }
    
    javax.microedition.lcdui.Form form1;
    javax.microedition.lcdui.StringItem stringItem1;
    javax.microedition.lcdui.StringItem stringItem2;
    javax.microedition.lcdui.TextField textField1;
// --- This is the end of auto-generated section.//</editor-fold>//GEN-END:MVDMethods
    
    public void startApp() {
        initialize();
    }
    
    private void callWebService() {
        WSRequest wsRequest = new WSRequest("http://localhost:8080/axis/Servico.jws", "soma", "get");
        wsRequest.put("valor1", "10");
        wsRequest.put("valor2", "10");
        WSController wsController = new WSController(wsRequest);
/*        SoapObject soapObject = null;
        try {
//            wsController.prepare();
//            SoapObject s = (SoapObject)wsController.getTransport().call(wsController.getSoapClient());
            soapObject = wsController.call();
        } catch (IOException ioEx) {
            System.out.println("Call Error (callWebService): IOException: " + ioEx.getMessage());
        }
        for (int i = 0; i < soapObject.getPropertyCount(); i++) {
            SoapObject soapProperty = (SoapObject)soapObject.getProperty(i);
            System.out.println(soapProperty);
//            System.out.println(soapProperty.getProperty("key"));
//            System.out.println(soapProperty.getProperty("value"));
        }
        
  */      
    } 
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
    
}
